<?php
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail.com
 * @since		1.0
 */

class Modules_Core_Controllers_Dashboard extends Gio_Core_Controller
{
	public function indexAction()
	{
		$this->view->phpVersion = phpversion();
		$this->view->databaseVersion = Gio_Db_Mysql::getInstance()->getVersion();
		
		$configs = Gio_Core_Config_Xml::getConfig('install');
		$this->view->installInformation = $configs;
		
		
		$modules = Modules_Core_Services_Module::getModulesInstalled();
		/**
		 * Add module core to the top array 
		 */
		$modules = array_pad($modules, -count($modules) - 1, array('module_id' => 'core'));
		
		$quickaccess = array();
		if ($modules) {
			foreach ($modules as $index => $module) {
				$aboutXml = MOD_DIR . DS . $module['module_id'] . DS . 'configs' . DS . 'about.xml';
				if (!file_exists($aboutXml)) {
					continue;
				}
				$aboutXml = @simplexml_load_file($aboutXml);
				$items = (isset($aboutXml->admin->quickaccess->item)) 
							? $aboutXml->admin->quickaccess->item : null;
				if ($items) {
					foreach ($items as $item) {
						$data = array();
						$data['module'] = $module['module_id'];
						$data['route'] = $item->route;
						$data['lang_key'] = $item->lang_key;
						$data['thumbnail'] = $item->thumbnail;
						$quickaccess[] = $data;
					}	
				}
			}
		}
		$this->view->quickaccess = $quickaccess;
	}
}